<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		
		<style>
			th,td{
				
				padding:10px 25px 10px 10px;
			}
			th{
				color: white;
				border:0.5px solid white;
				background-color: #09c;
				font-size: 17px;
				border-bottom: none;
			}
			td{
				border:1px solid lightslategrey;
				
			}
			table{
				border-collapse: collapse;
				margin:0 auto;
				font-size:14px;
			}
		</style>
		<script>
			onload = function(){
			var topInp = document.getElementById("theadInp");
            var tbody = document.getElementById("tbody");
            var botInpArr = tbody.getElementsByTagName("input");
            topInp.onclick = function(){
				for(var i=0;i<botInpArr.length;i++){
					botInpArr[i].checked = this.checked;
				}   	
            }
			
            for(var i=0;i<botInpArr.length;i++){
                botInpArr[i].onclick = function () {
                    var bool = true;
                    for(var j=0;j<botInpArr.length;j++){
                        if(botInpArr[j].checked == false){
                            bool = false;
                        }
                    }
                    topInp.checked = bool;
                }
            }


			}
		</script>
	</head>

	<body>
		<div class="wrap">
			<table>
				<thead>
					<tr>
						<th>
							<input type="checkbox" id="theadInp" />
						</th>
						<th>菜名</th>
						<th>饭店</th>
					</tr>
				</thead>
				<tbody id="tbody">
					<tr>
						<td>
							<input type="checkbox" />
						</td>
						<td>地三鲜</td>
						<td>田老师</td>
					</tr>
					<tr>
						<td>
							<input type="checkbox" />
						</td>
						<td>西红柿鸡蛋</td>
						<td>田老师</td>
					</tr>
					<tr>
						<td>
							<input type="checkbox" />
						</td>
						<td>醋溜土豆丝</td>
						<td>田老师</td>
					</tr>
					<tr>
						<td>
							<input type="checkbox" />
						</td>
						<td>萝卜干炒黄豆儿</td>
						<td>田老师</td>
					</tr>
				</tbody>
			</table>
		</div>

	</body>

</html>